//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#ifndef __PSEUDOOBJECT_H__
#define __PSEUDOOBJECT_H__

#include <elasys_server.h>
#include "linknode.h"

typedef Int32 PseudoObjectType;

enum {
    PseudoObjectType_Process = 0,
    PseudoObjectType_Thread  = 1,
    PseudoObjectType_Module  = 2,
    PseudoObjectType_Butt    = 3
};

class PseudoObjectFactory;

class PseudoObject : public DLinkNode
{
public:
    virtual PInterface GetObject() = 0;
    virtual Boolean Compare(PVoid pCompareData) = 0;

public:
    STATIC DLinkNode s_list[PseudoObjectType_Butt];
    STATIC PVoid s_hLock[PseudoObjectType_Butt];

    STATIC ECode S_Initialize();
    STATIC void  S_Destroy();

    STATIC ECode S_Create(
            /* [in] */ PseudoObjectFactory * pFactory,
            /* [out] */ PseudoObject ** ppPseudoObject);

    STATIC ECode S_Attach(
            /* [in] */ PseudoObjectType type,
            /* [in] */ PseudoObject * pPseudoObject);

    STATIC ECode S_Delete(
            /* [in] */ PseudoObjectType type,
            /* [in] */ PseudoObject * pPseudoObject);
};

class PseudoObjectFactory
{
public:
    virtual ECode CreateObject(
        /* [out] */ PseudoObject ** ppPseudoObject) = 0;

    virtual Boolean Compare(
        /* [in] */ PseudoObject * pPseudoObject) = 0;

    virtual PseudoObjectType GetType() = 0;
};

#endif //__PSEUDOOBJECT_H__
